const Router = require('koa-router')
const CommodityModel = require('../models/commodity')

const route = new Router({ prefix: '/api/commodity' })

route.get('/all', async (ctx) => {
    let res = {
        success: false
    }

    try {
        res.data = await CommodityModel.find()
        res.success = true
    } catch (error) {
        res.error = error.message
        ctx.status = 500
    }

    ctx.body = res
})

module.exports = route
